package servlet.tea;

import com.alibaba.fastjson.JSONObject;
import entity.Homework;
import entity.StuWork;
import util.JdbcUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/querystatus")
public class ClassifyServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("work_id");
        JSONObject respJson = new JSONObject();

        String sql = "select * from stu_work where id = ?";
        StuWork stuWork = JdbcUtil.queryOne(StuWork.class, sql, id);
        if(stuWork != null){
            respJson.put("msg", "yes");
        }else{
            respJson.put("msg", "no");
        }

        respJson.put("code", 200);
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("application/json");
        resp.getWriter().write(String.valueOf(respJson));
    }
}
